package br.edu.ufcg.greengrid.model.machine.state;

import br.edu.ufcg.greengrid.model.machine.Machine;

public class GreenifiableIdleMachineState extends IdleMachineState {
	
	//TODO Refactor this method. Its implementation is similar to the same method implemented at IdleMachineState
	@Override
	public void changeStateIfNeeded(Machine m) {
		MSEnum newStateType = null;
		long countdown = 0L;
		
		if(isCountdownZero()){
			newStateType = MSEnum.USER;
			countdown = 0L;
		} else {
			newStateType = MSEnum.GOING_GREEN;
			countdown = this.countdown;
		}
		
		if(newStateType != null){
			m.changeState(newStateType, countdown);
		}
	}
	
}
